<?php
namespace App\Models;


/**
 * 收货地址类
 */
class MBdzxLog extends BaseModel
{
    public $table = "bdzx_logs";

    const bdzx_sh_apply = 0;  //申请中
    const bdzx_sh_yes = 1;    //申请成功
    const bdzx_sh_no = 2;    //申请失败
    /**
     * 记录一条报单中心日志
     * uid 申请报单人
     * method 申请报单方式 1 奖金币 2奖金币+报单币
     * jjb 报单花费的奖金币
     * bdb 报单花费的报单币
     * z_money 报单花费的总币
     * time  报单申请时间
     * status 审核状态
     * result 后台审核描述
     */
    public static function bdzxlog ($uid,$username,$method,$jjb,$bdb,$z_money)
    {
        $log = new MBdzxLog();
        $log->no = onlyNo();
        $log->uid = $uid;
        $log->username = $username;
        $log->method = $method;
        $log->jjb = $jjb;
        $log->bdb = $bdb;
        $log->z_money = $z_money;
        $log->time = time();
        $log->status = MBdzxLog::bdzx_sh_apply;
        return $log->save();
    }

    /**
     * 通过申请
     */
    public function allow($result)
    {
        $this->status = MBdzxLog::bdzx_sh_yes;
        $this->result = $result;
        return $this->save();
    }

    /**
     *拒绝申请
     */
    public function deny($result)
    {
        //修改状态并补充拒绝缘由
        $this->status = MBdzxLog::bdzx_sh_no;
        $this->result = $result;
        return $this->save();
    }
}